#ifndef PORTLISTWIDGET_H
#define PORTLISTWIDGET_H

#include <QWidget>
#include "ConnectItemModel.h"
#include <QThread>

namespace Ui {
class PortListWidget;
}

class PortListWidget : public QWidget
{
	Q_OBJECT

	ConnectItemModel* _model;
	QList<PortConnectInfo> _ports;

	Ui::PortListWidget *ui;

public:
	explicit PortListWidget(QWidget *parent = 0);
	~PortListWidget();

private slots:
	void onUpdateBtn();
	void addPortInfo(PortConnectInfo info);
	void onFinished();
};

class EnumeratePorts : public QThread
{
	Q_OBJECT

	bool _isRunning;
	PortListWidget* _widget;
public:
	explicit EnumeratePorts(QObject* parent = 0);
	void stop();
	void setWidget(PortListWidget* widget);
protected:
	void run();

signals:
	void portAdded(PortConnectInfo info);
};

#endif // PORTLISTWIDGET_H
